from django_filters import rest_framework

from article.models import Article


class ArticleTitleFilter(rest_framework.FilterSet):
    """
    自定义文章标题过滤器类,实现对文章标题进行模糊搜索(不区分大小写)
    """

    title = rest_framework.CharFilter(field_name='title', lookup_expr='icontains', label='文章标题(模糊搜索且不区分大小写)')
    author = rest_framework.CharFilter(field_name='author', lookup_expr='icontains', label='文章作者(模糊搜索且不区分大小写)')


    class Meta:
        model = Article
        fields = ['title', 'author']

